package factory_pattern.calculator01;

/**
 * @Author xiumu
 * @Date 2020/7/5 10:11
 */
public class Operator {
    public static double calculate(double firstNumber,double secondNumber,char oper){
        double result = 0;
        switch (oper){
            case '+':
                result = firstNumber+secondNumber;
                break;
            case '-':
                result = firstNumber-secondNumber;
                break;
            case '*':
                result = firstNumber*secondNumber;
                break;
            case '/':
                if (secondNumber==0){
                    System.out.println("输入不合法");
                    break;
                }
                result = firstNumber/secondNumber;
                break;
        }
        return result;
    }
}
